package com.youmans.eduservice.controller;


import com.youmans.commonutils.R;
import com.youmans.eduservice.entity.subject.Subject;
import com.youmans.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author Youmans
 * @since 2022-05-06
 */
@Api(tags = "课程分类控制器")
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService ;

    @ApiOperation("添加课程分类")
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        //上传过来的Excel文件
        subjectService.saveSubject(file,subjectService) ;
        return R.ok() ;
    }

    @ApiOperation("课程分类列表")
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<Subject> list = subjectService.getAllSubject() ;
        return R.ok().data("list",list) ;
    }
}

